%&plain

\def\topic#1{\medskip\noindent{\bf #1}}
\def\\{\hbox{$\backslash$}}
\def\cite{\smallskip\tt\obeylines\parindent0pt}

\magnification1200
\nopagenumbers

\centerline{\bf Using Vim and MikTeX on Windows 95 (98? NT?)}
\bigskip

These are the steps I have used to get Vim and Mik\TeX{} to cooperate on
Windows~95.  I mostly use plain \TeX{}, but it should be easy to modify
these instructions to use La\TeX{} or some other variant.  Aside from
getting the two programs to cooperate, I wanted to specify where I keep
my \TeX{} macros, so I also explain how to do that.

Make sure to get the OLE version of Vim.  (``OLE'' stands for ``Object
Linking and Embedding.''  This version of Vim acts as an ``OLE server.''
I do not really know what this means, but it seems to be a mechanism for
inter-process communication.)
The response to
{\tt :version}
should mention the OLE support.
Then, add appropriate lines to your
{\tt autoexec.bat}
file so that the folder containing {\tt OpenWithVim.exe} and
{\tt SendToVim.exe} is in your path.  While you are at it, make sure
that the Mik\TeX{} executables are in your path.  I have it set up so
that the non-OLE version is in the path, so I get that version if I just
type {\tt gvim}.  Here is the appropriate line from my {\tt
autoexec.bat}:
{\cite
set VIM=D:\\vim
set PATH=\%PATH\%;D:\\vim\\vim55;D:\\vim\\OLEvim55\\OleVim;C:\\WINDOWS\\SYSTEM;D:\\texmf\\miktex\\bin
\smallskip}
If you prefer not to add these files to your path, you should specify
full paths in the following.

\topic{Setting up Vim:}
Assuming that you are using the default vimrc and gvimrc files, many
things will work automatically.  In particular, if you start editing a
file ending in ``.tex'' (?or ``.sty''?) then Vim will assume it is a
\TeX{} source file and automatically load the appropriate syntax file.
There are some options you will probably want to modify and you may also
want to enable ``smart quotes.''  You will certainly want to set up
macros, commands, and/or menu items to invoke tex and yap on your source
file.

Here are the appropriate lines from my vimrc file:
{\cite
" Assume the cursor is on a " and return TeX-style open quotes or close
" quotes appropriately.
function! TeXquote()
  let q = "``"
  let l = line(".")
  let c = col(".")
  let temp = \&wrapscan
  set wrapscan
  execute 'normal ?\^\$\\|"\\|``\\|' . "''\\r"
  if ( line(".") < l || line(".") == l \&\& col(".") < c )
    if strlen(getline("."))
      if ( getline(".")[col(".")-1] == "`" )
        let q = "''"
      endif
    endif
  endif
  execute "normal /\\"\\r"
  let \&wrapscan = temp
  return q
endfunction

function! TeXandPreview()
  if has("win32")
    cd \%:p:h
    w
    !tex --src-specials \%:p
    execute '!start yap -1 -s ' . line(".") . " " . expand("\%:p:r")
  endif
endfunction

" Group autocommands under the heading "TeX":
augroup TeX
  " Remove all TeX autocommands
  au!
" Break lines (at a word boundary) after 70 characters.  This works well
" for ordinary text.  You may find it annoying for complicated
" equations, tables, and so on.
set tw=70
" Invoke TeXquote() by typing " in Insert or Replace mode.  Define this mapping
" when starting to edit a file of type *.tex or *.sty and undefine the
" mapping when exiting such a file.  These two autocommands should each be
" one line; fix it if the lines have been broken!
  autocmd BufEnter *.tex,*.sty ino " "<Left><C-O>:let@9=TeXquote()<CR><Del><C-R>9
  autocmd BufEnter *.tex,*.sty nno ,t :call TeXandPreview()<CR>
  autocmd BufLeave *.tex,*.sty iunmap "
  autocmd BufLeave *.tex,*.sty nunmap ,t
augroup END
\smallskip}

\topic{Setting up Mik\TeX:}
This is what I did to set up Mik\TeX.  Modify or skip these instructions
to suit your fancy.

Copy the file
{\tt texmf\\miktex\\config\\miktex.ini}
to
{\tt \\localtexmf\\config\\miktex.ini}.
Delete or comment out almost everything, since you only want to change a
few of the defaults.  If you have you own macro files, go to the [TeX]
and [pdfTeX] sections and add something appropriate to the ``Input
Dirs'' line.  Here is what I have (leaving out most of the lines that I
commented out):
{\cite
;; miktex.ini -- local MiKTeX Configuration File
;; Time-stamp: "1999-08-13 11:57 Benji Fisher"
;;
;; This is the local configuration file for TeX and friends.
;; I copied the global miktex.ini and changed the lines I wanted to
;; change and commented out the rest.

[pdfTeX]

;; Where pdfTeX searches for input files.
Input Dirs=.;E:\\TeX\\Inputs//;\%R\\pdftex\\plain//;\%R\\pdftex\\generic//;\%R\\pdftex//;\%R\\tex\\plain//;\%R\\tex\\generic//;\%R\\tex//

[TeX]

;; Where TeX looks for input files.
Input Dirs=.;E:\\TeX\\Inputs//;\%R\\tex\\plain//;\%R\\tex\\generic//;\%R\\tex//

Editor=D:\\vim\\OLEvim55\\OleVim\\OpenWithVim +\%l \%f
\smallskip}
That last line, of course, is crucial.  It tells {\tt tex} to invoke Vim
if you type ``{\tt e}'' at the prompt.

After editing this configuration file, open a DOS window.
Assuming that the Mik\TeX{} binaries are already in your path, or you
are in the directory containing these binaries, type\hfill\break
{\tt initex --personal=\\localtexmf\\config\\miktex.ini}.

\topic{Setting up Yap:}
This part is easy.  Start up Yap.  From the File menu, choose
Options$\ldots\,$, and the Inverse~Search tab.  In the Command~line
box, enter
{\tt OpenWithVim +\%l \%f}.
\bye
